package com.it.base.thread.pool.newScheduledThreadPoolDemo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 创建一个可定期或者延时执行任务的定长线程池，支持定时及周期性任务执行。
 */
public class MyNewScheduledThreadPoolExecutor {

    private static ExecutorService executorService=   Executors.newScheduledThreadPool(2);

    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getName());
        for(int i=0;i<100;i++){
            executorService.execute(()->System.out.println(Thread.currentThread().getName()));
        }
        executorService.shutdown();

    }

}
